const adminChild = [

    {
        path: '/admin/InfoManage',
        name: 'InfoManage',
        component: () => import('@/views/admin/InfoManage.vue')
    },
    {
        path: '/admin/ExtraManage',
        name: 'ExtraManage',
        component: () => import('@/views/admin/ExtraManage.vue')
    },
    {
        path: '/admin/VisitManage',
        name: 'VisitManage',
        component: () => import('@/views/admin/VisitManage.vue')
    },
    {
        path: '/admin/TimeSet',
        name: 'TimeSet',
        component: () => import('@/views/admin/TimeSet.vue')
    },
    {
        path: '/admin/Statistics',
        name: 'Statistics',
        component: () => import('@/views/admin/Statistics.vue')
    },
]

const assisterChild = [
    {
        path: '/assister/ConsultChange',
        name: 'ConsultChange',
        component: () => import('@/views/assister/ConsultChange.vue')
    },
    {
        path: '/assister/ConsultCheck',
        name: 'ConsultCheck',
        component: () => import('@/views/assister/ConsultCheck.vue')
    },
    {
        path: '/assister/ExtraCheck',
        name: 'ExtraCheck',
        component: () => import('@/views/assister/ExtraCheck.vue')
    },
]

const consultorChild = [
    {
        path: '/consultor/ConsultRecord',
        name: 'ConsultRecordConsultor',
        component: () => import('@/views/consultor/ConsultRecord.vue')
    },
    {
        path: '/consultor/VisitRecord',
        name: 'VisitRecordConsultor',
        component: () => import('@/views/consultor/VisitRecord.vue')
    },
    {
        path: '/consultor/AddConsult',
        name: 'addConsult',
        component: () => import('@/views/consultor/AddConsult.vue')
    }
]

const studentChild = [
    {
        path: '/student/ConsultRecord',
        name: 'ConsultRecord',
        component: () => import('@/views/student/ConsultRecord.vue')
    },
    {
        path: '/student/VisitRecord',
        name: 'VisitRecord',
        component: () => import('@/views/student/VisitRecord.vue')
    },
    {
        path: '/student/OrderFirstVisit',
        name: 'OrderFirstVisit',
        component: () => import('@/views/student/OrderFirstVisit.vue')
    },
    {
        path: '/student/Init',
        name: 'Init',
        component: () => import('@/views/student/StudentInit.vue')
    }
]

const routes = [

    //访问路由“/”,自动重定向到"/home"
    {
        path: '/',
        redirect: '/security/Login'
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    },
    {
        path: '/security/Register',
        name: "Register",
        component: () => import('@/views/security/Register.vue')
    },
    {
        path: '/security/Login',
        name: "Login",
        component: () => import('@/views/security/Login.vue')
    },
    {
        path: '/security/UpdatePassword',
        name: "UpdatePassword",
        component: () => import('@/views/security/UpdatePassword.vue')
    },
    {
        path: '/security/RegisteMail',
        name: "RegisteMail",
        component: () => import('@/views/security/RegisteMail.vue')
    },
    {
        path: '/security/ForgetPwd',
        name: "ForgetPwd",
        component: () => import('@/views/security/ForgetPwd.vue')
    },
    {
        path: '/admin/AdminHome',
        name: "AdminHome",
        component: () => import('@/views/admin/AdminHome.vue'),
        children: adminChild
    },
    {
        path: '/assister/AssisterHome',
        name: "AssisterHome",
        component: () => import('@/views/assister/AssisterHome.vue'),
        children: assisterChild
    },
    {
        path: '/consultor/ConsultorHome',
        name: "ConsultorHome",
        component: () => import('@/views/consultor/ConsultorHome.vue'),
        children: consultorChild
    },
    {
        path: '/student/StudentHome',
        name: "StudentHome",
        component: () => import('@/views/student/StudentHome.vue'),
        children: studentChild
    },

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;